package com.dk.service.impl;

import com.dk.mapper.TabRouteImgMapper;
import com.dk.pojo.TabRoute;
import com.dk.pojo.TabRouteImg;
import com.dk.service.TabRouteImgService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class TabRouteImgServiceImpl implements TabRouteImgService {

    @Autowired
    private TabRouteImgMapper tabRouteImgMapper;

    @Override
    public List<TabRouteImg> getInfo(Integer rid) {
        return tabRouteImgMapper.select(rid);
    }

    @Override
    public int insert(TabRouteImg tabRouteImg) {
        String bigpic = tabRouteImg.getBigpic();
        String smallpic = tabRouteImg.getSmallpic();
        String big = "img/product/size4/" + bigpic;
        String small = "img/product/size2/" + smallpic;
        tabRouteImg.setBigpic(big);
        tabRouteImg.setSmallpic(small);
        return tabRouteImgMapper.insert(tabRouteImg);
    }

    @Override
    public TabRouteImg selectById(Integer cid) {
        return tabRouteImgMapper.selectByPrimaryKey(cid);
    }

    @Override
    public int updateInfo(TabRouteImg tabRouteImg) {
        String bigpic = tabRouteImg.getBigpic();
        String smallpic = tabRouteImg.getSmallpic();
        String big = "img/product//size4/" + bigpic;
        String small = "img/product/size2/" + smallpic;
        tabRouteImg.setBigpic(big);
        tabRouteImg.setSmallpic(small);
        return tabRouteImgMapper.updateByPrimaryKey(tabRouteImg);
    }

    @Override
    public int deleteById(Integer rgid) {
        return tabRouteImgMapper.deleteByPrimaryKey(rgid);
    }
}
